import axiosInstance from "../utils/axios.ts";
import type {ProjectDTO, ProjectVO} from "../types/project";
import {type MaybeRef, unref} from "vue";

export const getProjects = (companyId: MaybeRef<number | undefined>) => {
  return axiosInstance.post<any, ProjectDTO[]>("/contract/getList", undefined, {
    params: {
      id: unref(companyId)
    }
  })
}

export const insertProject = (project: ProjectVO) => {
  return axiosInstance.post("/contract/save", project)
}

export const deleteProject = (id: number) => {
  return axiosInstance.delete("/contract/delete", {
    params: {
      id
    }
  })
}

export const updateProject = (project: ProjectVO) => {
  return axiosInstance.put("/contract/update", project)
}